package com.sc1905.crane.reading.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sc1905.crane.mapper.NChapterMapper;
import com.sc1905.crane.pojo.NChapter;
import com.sc1905.crane.reading.service.ChapterService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ChapterServiceImpl implements ChapterService {

    @Resource
    NChapterMapper chapterMapper;

    @Override
    public List<NChapter> novelChapter(Integer novelId) {
        return chapterMapper.chapterList(novelId);
    }

    @Override
    public NChapter chapterContent(Integer chapterId) {
        return chapterMapper.selectByPrimaryKey(chapterId);
    }

    @Override
    public String chapterPrice(Integer novelId) {
        return chapterMapper.chapterPrice(novelId);
    }

    @Override
    public PageInfo<NChapter> chapterPage(Integer novelId, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<NChapter> nChapters = chapterMapper.chapterList(novelId);
        return new PageInfo<NChapter>(nChapters);
    }

    @Override
    public NChapter firstRead() {
        return chapterMapper.firstRead();
    }


}
